import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_learn_vi/src/bean/bean_video_course.dart';
import 'package:flutter_learn_vi/src/page/study/course/main_course_page.dart';
import 'package:flutter_learn_vi/src/utils/navigator_utils.dart';

/// 创建人： Created by zhaolong
/// 创建时间：Created by  on 2021/1/14.
///
/// 可关注公众号：我的大前端生涯   获取最新技术分享
/// 可关注网易云课堂：https://study.163.com/instructor/1021406098.htm
/// 可关注博客：https://blog.csdn.net/zl18603543572
///
/// 代码清单
///代码清单
class TrainCourseVideoItemWidget extends StatefulWidget {
  final BeanVideoCourse videoCourse;
  final int index;
  final int trainId;

  const TrainCourseVideoItemWidget({
    Key key,
    this.videoCourse,
    this.index,
    this.trainId,
  }) : super(key: key);

  @override
  _TrainCourseVideoItemWidgetState createState() =>
      _TrainCourseVideoItemWidgetState();
}

class _TrainCourseVideoItemWidgetState extends State<TrainCourseVideoItemWidget>
    with SingleTickerProviderStateMixin {
  @override
  void initState() {
    super.initState();
  }

  @override
  void dispose() {
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        NavigatorUtils.pushPage(
          context,
          MainCoursePage(
            beanVideoCourse: widget.videoCourse,
            isTrainSign: true,
            trainId: widget.trainId,
          ),
        );
      },
      child: Container(
        margin: EdgeInsets.only(top: 6),
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            Row(
              children: [
                ClipOval(
                  child: Container(
                    alignment: Alignment.center,
                    width: 14,
                    height: 14,
                    child: Text(
                      "${widget.index + 1}",
                      style: TextStyle(
                        color: Colors.white,
                        fontSize: 10,
                      ),
                    ),
                    decoration: BoxDecoration(
                        gradient: LinearGradient(colors: [
                      Colors.blueAccent,
                      Colors.lightBlueAccent,
                      Colors.blue,
                    ])),
                  ),
                ),
                SizedBox(
                  width: 8,
                ),
                Container(
                    padding: EdgeInsets.only(left: 4, right: 4),
                    decoration: BoxDecoration(
                      borderRadius: BorderRadius.all(Radius.circular(4)),
                      border: Border.all(color: Colors.blueGrey),
                    ),
                    child: Text(
                      "在线课程",
                      style: TextStyle(fontSize: 10),
                    )),
                SizedBox(
                  width: 8,
                ),
                Expanded(child: Text("${widget.videoCourse.videoCourseName}")),
                SizedBox(
                  width: 8,
                ),
                Text(
                  "立即学习",
                  style: TextStyle(fontSize: 12, color: Colors.green),
                ),
                Icon(
                  Icons.arrow_forward_ios,
                  size: 14,
                  color: Colors.green,
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}
